   // MyQueue.h: interface for the MyQueue class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(MYQUEUE_H)
#define MYQUEUE_H

#pragma once

#ifdef _DEBUG
#undef new
#endif

#include "CriticalSectionClass.h"
#include <list>


//##ModelId=4396837902F7
template <class T> class MyQueue : public CCriticalSectionClass
{
private:
	//##ModelId=43968379031B
	std::list<T>		m_queue;
public:

	//##ModelId=439683790326
	MyQueue(){}
	//##ModelId=439683790327
	virtual	~MyQueue(){}

	//##ModelId=439683790329
	std::list<T>* GetList(){return &m_queue;}
	//##ModelId=43968379032A
	void	EmptyAll()
	{
		EnterCritical();
		m_queue.clear();
		LeaveCritical();
	}
	//##ModelId=43968379032B
	int GetSize()
	{
		int size=0;
		EnterCritical();
		size = (int)(m_queue.size());
		LeaveCritical();
		return size;
	}

	//##ModelId=439683790337
	BOOL	Push(T	pNode,int	nLine=0)
	{
		BOOL	bResult=TRUE;
		
		EnterCritical();
		m_queue.push_back(pNode);
		LeaveCritical();
		return	bResult;
	}
	
	//##ModelId=43968379033A
	BOOL	IsEmpty()
	{
		BOOL	bEmpty=TRUE;
		
		EnterCritical();
		bEmpty=m_queue.empty();
		LeaveCritical();
		return	bEmpty;
	}
	
	//##ModelId=43968379033B
	BOOL	Pop(T*	pPointer)
	{
		BOOL	bEmpty=TRUE;
		
		if(pPointer==NULL )
			return	FALSE;
		EnterCritical();
		bEmpty=m_queue.empty();
		if(bEmpty==FALSE)
		{
			*pPointer=m_queue.front();
			m_queue.pop_front();
		}
		LeaveCritical();
		return	!bEmpty;
	}
	//##ModelId=43968379033D
	BOOL	GetFrontData(T*	pPointer)
	{
		BOOL	bEmpty=TRUE;
		
		if(pPointer==NULL )
			return	FALSE;
		EnterCritical();
		bEmpty=m_queue.empty();
		if(bEmpty==FALSE)
			*pPointer=m_queue.front();
		LeaveCritical();
		return	!bEmpty;
	}
	//##ModelId=43968379033F
	BOOL	PopData()
	{
		BOOL	bEmpty=TRUE;
		
		EnterCritical();
		bEmpty=m_queue.empty();
		if(bEmpty==FALSE)
			m_queue.pop_front();
		LeaveCritical();
		return	!bEmpty;
	}

};




#endif // !defined(MYQUEUE_H)
